
import request from '@/utils/request'
import system from '@/api/system'
const customer = {
  getCustomerInfoListAPI: (params) => {
    return request({
      url: '/crm/customer/list',
      method: 'post',
      data: params
    })
  },
  getCustomerSourceChannelListAPI: async (bizType = 'customerSource') => {
    const res = await system.getDictListByBizTypeAPI(bizType)
    return res
  },
  getCustomerContactsListAPI: (customerCode) => {
    return request({
      url: `/crm/contacts/list/${customerCode}`,
      method: 'get'
    })
  },
  queryContactsListAPI: (params) => {
    return request({
      url: `/crm/contacts/list`,
      method: 'post',
      data: params
    })
  },
  getCustomerContractListAPI: (customerCode) => {
    return request({
      url: '/crm/customer/contract/list/' + customerCode,
      method: 'get'
    })
  },
  getCustomerOrderListAPI: (customerCode) => {
    return request({
      url: '/crm/customer/order/list/' + customerCode,
      method: 'get'
    })
  },
  updateCustomerInfoAPI: (customerInfo) => {
    return request({
      url: '/crm/customer/update/' + customerInfo.id,
      method: 'put',
      data: customerInfo
    })
  },
  saveCustomerInfoAPI: (customerInfo) => {
    return request({
      url: '/crm/customer/save',
      method: 'post',
      data: customerInfo
    })
  },
  deleteCustomerInfoAPI: (customerId) => {
    return request({
      url: '/crm/customer/delete/' + customerId,
      method: 'delete'
    })
  },
  getCustomerInfoAPI: (customerCode) => {
    return request({
      url: '/crm/customer/get/' + customerCode,
      method: 'get'
    })
  },
  updateContactsInfosAPI: (contactsInfo) => {
    return request({
      url: '/crm/contacts/update/' + contactsInfo.id,
      method: 'put',
      data: contactsInfo
    })
  },
  addContactsInfosAPI: (contactsInfo) => {
    return request({
      url: '/crm/contacts/add',
      method: 'post',
      data: contactsInfo
    })
  },
  deleteContactsInfosAPI: (contactsId) => {
    return request({
      url: '/crm/contacts/delete/' + contactsId,
      method: 'delete'
    })
  },
  getCustomerVisitInfoListAPI: function (customerCode) {
    return request({
      url: '/crm/customer/visit/list/' + customerCode,
      method: 'get'
    })
  },
  saveCustomerVisitInfoAPI: function (params) {
    return request({
      url: '/crm/customer/visit/save',
      method: 'post',
      data: params
    })
  },
  updateCustomerVisitInfoAPI: function (params) {
    return request({
      url: '/crm/customer/visit/update/' + params.visitCode,
      method: 'put',
      data: params
    })
  },
  deleteCustomerVisitInfoAPI: function (visitCode) {
    return request({
      url: '/crm/customer/visit/delete/' + visitCode,
      method: 'delete'
    })
  }
}
export default customer
